﻿
@{
    ViewData["Title"] = "管理员编辑";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model User

<article class="page-container">
    <form class="form form-horizontal" id="form-admin-add">
        <input hidden="hidden" name="id" value="@Model.Id"/>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>账号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Username" placeholder="" id="username" name="username" AUTOCOMPLETE="off">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>初始密码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="password" class="input-text" autocomplete="off" value="@Model.Password" placeholder="密码" id="password" name="password" >
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="password" class="input-text" autocomplete="off" value="@Model.Password"  placeholder="确认新密码" id="password2" name="password2">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>真实姓名：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Realname" placeholder="" id="realname" name="realname" AUTOCOMPLETE="off">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" AUTOCOMPLETE="off" class="input-text" value="@Model.Phone" placeholder="" id="phone" name="phone">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>

</article>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">

    $("#form-admin-add").validate({
        rules: {
            username: {
                required: true,
                minlength: 4,
                maxlength: 16
            },
            password: {
                required: true
            },
            password2: {
                required: true,
                equalTo: "#password"
            },
            realname: {
                required: true
            },
            phone: {
                required: true,
                isPhone: true
            }
        },
        onkeyup: false,
        focusCleanup: true,
        success: "valid",
        submitHandler: function (form) {
            $(form).ajaxSubmit({
                type: 'post',
                url: "/user/usereditprocess",
                dataType: "json",
                success: function (data) {
                    if (data.succeed) {
                        layer.msg('添加成功!', { icon: 1, time: 1500 }, function () {
                            window.parent.location.reload();
                            parent.layer.close(index);
                        });

                    } else {
                        layer.msg('添加失败!', { icon: 0, time: 1500 });
                    }

                },
                error: function (data) {
                    layer.msg('error!', { icon: 1, time: 1000 });
                }
            });

        }
    });
</script>
<!--/请在上方写此页面业务相关的脚本-->
